#include "mainwindow.h"

#include <QApplication>
#include <QDebug>
#include <Eigen/Core>
#include <iostream>
#include "IOType/PointCloud.h"
#include <string>
#include "assimp/Importer.hpp"
#include "assimp/scene.h"
#include "assimp/postprocess.h"
#include<OpenMesh/Core/IO/MeshIO.hh>
#include<OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>


int main(int argc, char *argv[])
{
    QString qpath ="D:/selfad/qtapp/qt-with-open-gl/objects/rock/rock.obj";
    Assimp::Importer importer;
    //const aiScene *scene=importer.ReadFile(qpath.toLatin1(),aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_CalcTangentSpace);

    Eigen::Vector3d X0(1,2,3);
    //std::cout<<X0;
    QString str = QString("%1 %2 %3").arg(X0.x()).arg(X0.y()).arg(X0.z());
    qDebug() << str;
    std::string path = "D:/selfad/qtapp/includeTest/3DAlgorithm/commonFunc/BasicTools/include/IOType/point.asc";
    std::vector<Eigen::Vector3d> cld;
    PointCloud::readPoint(path, cld);

    for(auto &p: cld)
    {
        qDebug()<<"x="<<p.x()<<" y="<<p.y()<<" z="<<p.z();
    }
    using MyMesh = OpenMesh::TriMesh_ArrayKernelT<>;
    MyMesh mesh;
    MyMesh::VertexHandle vhandle[4];
    MyMesh::FaceHandle   fhandle;

    vhandle[0] = mesh.add_vertex(MyMesh::Point(-1, -1,  1));
    vhandle[1] = mesh.add_vertex(MyMesh::Point( 1, -1,  1));
    vhandle[2] = mesh.add_vertex(MyMesh::Point( 1,  1,  1));
    vhandle[3] = mesh.add_vertex(MyMesh::Point(-1,  1,  1));

    std::vector<MyMesh::VertexHandle>  face_vhandles;
    face_vhandles.push_back(vhandle[0]);
    face_vhandles.push_back(vhandle[1]);
    face_vhandles.push_back(vhandle[2]);
    face_vhandles.push_back(vhandle[3]);
    fhandle = mesh.add_face(face_vhandles);
    //OpenMesh::IO::read_mesh(mesh, "D:/selfad/qtapp/qt-with-open-gl/objects/rock/rock.obj");
    qDebug()<<mesh.n_vertices();
    qDebug()<<mesh.n_faces();

    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}
